package com.sumainfor.pc.gmio.controller;

import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.feign.Zfeign.ZzuulFeign;
import com.sumainfor.pc.gmio.service.WithdrawalCleanService;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 保洁房源
 * <p>
 *
 * @author: zhoucong
 * @create: 2019-05-31 16:35
 **/
@Controller
@RequestMapping("/withdrawalClean")
public class WithdrawalCleanController {


    @Autowired
    WithdrawalCleanService withdrawalCleanService;

    @Autowired
    ZzuulFeign zzuulFeign;




    /**
    * <p>
    * 保洁房源列表
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getIfCleanFeeList")
    public JsonResult getIfCleanFeeList(@RequestBody Map<String,Object> params, Pager pager){
        JsonResult result=new JsonResult();
//        if (params.get("user_id")!=null) {
//            params.put("LaunchId", params.get("user_id"));
//        }
        params.put("LaunchId", ContextUtils.getUserId());
        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
       Integer cout = withdrawalCleanService.getIfCleanFeeCount(params);

        System.out.println("数量"+cout);
        if (cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,0);
        }
        List<Map<String,Object>> getIfCleanFeeList = withdrawalCleanService.getIfCleanFeeList(params);
        return pageUtils.getJsonResult(getIfCleanFeeList, params, cout);
    }


    /**
    * <p>
    * 修改房源保洁状态
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/updateIfCleanFee")
    public JsonResult updateIfCleanFee(@RequestBody Map<String,Object> params){
        return withdrawalCleanService.updateIfCleanFee(params);
    }


    /**
    * <p>
    * 查询发起人下拉框列表
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getLoginName")
    public JsonResult getLoginName(@RequestBody Map<String,Object> params){
        return zzuulFeign.getLoginName(params);
    }

}
